{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": true,
    "pycharm": {
     "is_executing": false
    }
   },
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "import os\n",
    "import csv\n",
    "\n",
    "DIR_NAME = './redundancy/'\n",
    "FIG_SIZE = (10, 5)\n",
    "BAR_WIDTH = 0.2\n",
    "\n",
    "\n",
    "def filter_files(filenames, filter_rules=None, separator=None):\n",
    "    if filter_rules  is None:\n",
    "        filter_rules = [('*', '', 'default')]  # (positive-key, negative-key, alias)\n",
    "    if separator is None:\n",
    "        separator = ''\n",
    "    filenames_dict = {}\n",
    "    for filter_rule in filter_rules:\n",
    "        filenames_dict[filter_rule[2]] = []\n",
    "    for filename in filenames:\n",
    "        if os.path.splitext(filename)[1] != '.csv':\n",
    "            continue\n",
    "        filename_split = filename.rstrip('.csv').split(separator)\n",
    "        for filter_rule in filter_rules:\n",
    "            if filter_rule[0] in filename_split and filter_rule[1] not in filename_split:\n",
    "                filenames_dict[filter_rule[2]].append(filename)\n",
    "                break\n",
    "    return filenames_dict"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "outputs": [
    {
     "data": {
      "text/plain": "<Figure size 720x360 with 1 Axes>",
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAlkAAAE/CAYAAAB1vdadAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAfl0lEQVR4nO3de7gdVX3/8fcHwk1QkOsj12CJ9Ym1WjliWxVpVQQpRVvutGCLUqRUW/HnBRAjXoDWFqFQLbca44VblSIXUURKCRQJokBAMIliIq1CCGAQSUO+vz/2RDeHc8gOnMU5Ce/X8+yH2WvWzKyZfYb5ZM3as1NVSJIkaWytMd4NkCRJWh0ZsiRJkh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0MkOTLwGuBH1bVrV3ZbOCbVVVJbgUmj7KuP0jyPnp/aBsDs5N8C/h94IL8+tn+63T/3Ro4L8kLgLWBH/at6z+q6hHgkW4dOwEXjcUOS88So53b86tqZlfn88C7gE+OTxOl1cJr6Z1rvwBIMvxh5cu9K8lbu+lt6D2cfFNgKjCzu0auDVzf1XnCNRX4ajfvSwBVdU2S5yXZqKoeGNvdGhvP9pA12q8aPdo3vazv/TK6Y5bkCmALYBZwJPAvwFBVzU8yDViXXk/YA1X18hG28c/AP1XVxUl2odeDtdzw52r4nA1p5Yx2bntuSWNv+Hm0XpLvdtOfAb4PvAH4var6RZKr6V0jA3yjqg7oXzjJuox8TR1texP2PH62j8m6BnhLkuckWR94K/BfgyxYVW+qqpdX1dv59Yd/X3c/ee+uzkPAD5PsA5Cel3V1NwR+0k0fwuPtlWTdJJsAu9D7aSNJgxvt3N42ye91dQ4Arh2vBkqriWuAtyZZL8lzgT2BR7rr48ur6jP0rneLuoD1YuB3u2X/G3h1kh0AuvP1RYxyTe2zX1f/NcCDVfVg0z18Gp7VPVlV9Z0kn+XXv6d4FrDoKazngSRn0rsv/SMeH4oOAj6d5FhgLeBcemOuptG7jfgTen9o2/ct823gUmBb4KNV9YQf1ZY0uic5t+8ADknyr8APgE+PTwul1UN3rp0HfBe4m5E7Kr4GHJ7kFuBOetc8qureJG8DvpRk+VCaY6vqrie5pgIsSnIdvTFgfznGuzSmfOL7BNN1iy6uKseJSGMoyWTgkqr6rXFuiqSnqLvV+N6qmjXebRnEs/12oSRJUhP2ZEmSJDVgT5YkSVIDhixJkqQGDFmSJEkNGLIkSZIaMGRJkiQ1YMiSJElq4P8DlPwq2Up8HBcAAAAASUVORK5CYII=\n"
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "def v_pkt_loss_rate_per_flow(filename):\n",
    "    pass\n",
    "\n",
    "def v_pkt_loss_rate_per_test_case(filenames_dict):\n",
    "    x = []\n",
    "    y = []\n",
    "    for alias, filenames in filenames_dict.items():\n",
    "        filename = filenames[0]\n",
    "        x.append(alias)\n",
    "        with open(os.path.join(DIR_NAME, filename), 'r') as file:\n",
    "            reader = csv.reader(file)\n",
    "            all_no_of_sent_pkt = 0\n",
    "            all_no_of_rcv_pkt = 0\n",
    "            for line in reader:  # [fid, sent_pkt, rcv_pkt, no_of_flow]\n",
    "                all_no_of_sent_pkt += int(line[1])\n",
    "                all_no_of_rcv_pkt += int(line[2]) / int(line[3])\n",
    "            pkt_loss_rate = (all_no_of_sent_pkt - all_no_of_rcv_pkt) / all_no_of_sent_pkt\n",
    "            y.append(pkt_loss_rate)\n",
    "    fig, ax = plt.subplots(figsize=FIG_SIZE)\n",
    "    ax.set_title(filename.rstrip('.csv'))\n",
    "    ax.bar(np.arange(len(x)), y, width=BAR_WIDTH, tick_label=x, label='pkt. loss rate', color=['r', 'g', 'b'])\n",
    "    for a, b in zip(np.arange(len(x)), y):\n",
    "        ax.text(a, b, '{:.2%}'.format(b), ha='center', va='bottom', fontsize=7)\n",
    "    plt.show()\n",
    "        \n",
    "filenames = os.listdir(DIR_NAME)\n",
    "filenames_dict = filter_files(filenames,  filter_rules=[\n",
    "    ('backtracking', 'o', 'om-aeap'), ('o', 'b', 'op'), ('dijkstra', 'o', 'd-aeap')], separator='-')\n",
    "\n",
    "v_pkt_loss_rate_per_test_case(filenames_dict)\n"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  },
  "pycharm": {
   "stem_cell": {
    "cell_type": "raw",
    "source": [],
    "metadata": {
     "collapsed": false
    }
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}